package com.attilax.rest;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;

import com.attilax.net.HttpUtil;

@WebServlet(name = "Proxy_name", urlPatterns = "/proxy")

public class Proxy implements Servlet {

	public static void main(String[] args) throws FileNotFoundException {
		FileOutputStream fos = new FileOutputStream("c:\\prox.txt");
		String url = "http://www.weather.com.cn/data/cityinfo/101250101.html";
		HttpUtil.sendGet2outStream(url, fos);
		System.out.println("ff");
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public ServletConfig getServletConfig() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getServletInfo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void init(ServletConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}

	@Override
	public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
	//	String url = "http://www.weather.com.cn/data/cityinfo/101250101.html";
		HttpUtil.sendGet2outStream(req.getParameter("url"), res.getOutputStream());

	}

}
